﻿@model  DroidClaim.Web.Models.SurveyorModel
@using DroidClaim.Web.CustomHelpers
@using DroidClaim.Web.Mapper
@{
    ViewBag.Title = "Edit Surveyor";
}
@section Styles {
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/form.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
    @*<link href="@Url.Content("~/Content/site2.css")" rel="stylesheet" type="text/css" />*@

    <script type="text/javascript">
        $(function () {
            //How to setup Datepicker
            // SetDatePicker has 4 argurement
            // controlId -> id of control
            // maxdate -> maximun Date that can be selected 
            // mindate -> minimum Date that can be selected 
            // yearrange - > range of year
            // more information see http://api.jqueryui.com/datepicker/

			            SetDatePicker("FreeDate");

            //How to setup Lookup
            // SetLookupFor has 3 argurement
            // controlId -> id of control
            // getLookupId -> hidden control's id for getlookup link
            // popLookupId -> hidden control's id for poplookup link
			// for each list<classLookup> -> Ple
							SetLookupFor("Surveyor_SurveyorLocation", "Surveyor_SurveyorLocationGetLookup", "Surveyor_SurveyorLocationPopLookup");
			            
        });
    </script>
}

<h2>Surveyor Detail</h2>
@using (Html.BeginForm("Update", "Surveyor", FormMethod.Post, new { @id = "form-Surveyor" }))
{
    @Html.ValidationSummary(false)
    <fieldset>
        <legend>SurveyorModel</legend>
		<div class="two-column-container">
      		
		
			
			 


			
				
            <div class="texteditor">
                @Html.LabelFor(model => model.Id)
				@Html.EditorFor(model => model.Id)
				            </div>												
						
			 


			
			
			<div class="texteditor">
				@Html.LabelFor(model => model.SurveyerId)
                @Html.TextBoxFor(model => model.SurveyerId)
							</div>

						
					
				
		
			
			 


			
			
			<div class="texteditor">
				@Html.LabelFor(model => model.Username)
                @Html.TextBoxFor(model => model.Username)
							</div>

						
			 


			
			
			<div class="texteditor">
				@Html.LabelFor(model => model.Password)
                @Html.TextBoxFor(model => model.Password)
							</div>

						
					
				
		
			
			 


			
			
			<div class="texteditor">
				@Html.LabelFor(model => model.Salt)
                @Html.TextBoxFor(model => model.Salt)
							</div>

						
			 


			
			
			<div class="texteditor">
				@Html.LabelFor(model => model.Name)
                @Html.TextBoxFor(model => model.Name)
							</div>

						
					
				
		
			
			 


			
			
			<div class="texteditor">
				@Html.LabelFor(model => model.Mobile)
                @Html.TextBoxFor(model => model.Mobile)
							</div>

						
			 


			
			
			<div class="texteditor">
				@Html.LabelFor(model => model.Email)
                @Html.TextBoxFor(model => model.Email)
							</div>

						
					
				
		
			
			 


			
			
			<div class="texteditor">
				@Html.LabelFor(model => model.PicturePath)
                @Html.TextBoxFor(model => model.PicturePath)
							</div>

						
			 


			
			
			<div class="texteditor">
				@Html.LabelFor(model => model.Code)
                @Html.TextBoxFor(model => model.Code)
									@Html.HiddenFor(model => model.Id)
					<input type="hidden" name="Mode" value="Edit" />
					<input type="hidden" name="OldValue" value="@(Model.Code == null ? "" : Model.Code )" />
							</div>

						
					
				
		
			
			 


			
					
            <div class="texteditor">
                @Html.LabelFor(model => model.SurveyorLocation)
                @Html.Lookup("Surveyor_SurveyorLocation").For(model => model.SurveyorLocation).WithCode(model => model.SurveyorLocationCode).WithName(model => model.SurveyorLocationName).Render()
                            </div>
			
						
			
		</div>
		
				<div class="bottom-menu clear">
            <input type="button" name="btnBack" value="Cancel" id="button-back" onclick="location.href='@Url.Action("ListSurveyor", "Surveyor")'"/>
            <input type="Button" value="Save" id="button-save" onclick="JavaScript: SaveButtonClick()" />
            <input type="button" name="btnDelete" value="Delete" id="button-delete" onclick="JavaScript: DeleteButtonClick()" />
        </div>
    </fieldset>
}

<div id="confirm-delete" title="Confirm delete." style="display: none">
    <span>Do you want to delete?</span>
</div>

<div id="confirm-save" title="Confirm save." style="display: none">
    <span>Do you want to save?</span>
</div>

<script type="text/javascript">
    function DeleteButtonClick() {
        $("#confirm-delete").dialog({
            modal:true,
            buttons: {
                Yes: function () {
                    $(this).dialog("close");

                    $.post('@Url.Action("DeleteSurveyorById", "Surveyor")',$("#form-Surveyor").serialize(),function (data) {
                        if (data == "Success") {
                            window.location.href = '@Url.Action("ListSurveyor", "Surveyor")';
                        }                        
                    });

                },
                No:function(){
                    $(this).dialog("close");
                }
            }
        })
    }

    function SaveButtonClick() {
        $("#confirm-save").dialog({
            modal: true,
            buttons: {
                Yes: function () {
                    $(this).dialog("close");
                    $("#form-Surveyor").submit();
                },
                No: function () {
                    $(this).dialog("close");
                }
            }
        })
    }
</script>